﻿@model IEnumerable<TravelWeb.Models.Promotion>
@{
    ViewBag.Title = "Promotion";
}
<h2>
    Promotion</h2>
<p>
    @if (User.IsInRole("Manager"))
    {
        @Html.ActionLink("Create New", "Create");
    }
</p>
<table>
    <tr>
        <th>
            Name
        </th>
        <th>
            Type
        </th>
        <th>
            Discount
        </th>
        <th>
            Start
        </th>
        <th>
            End
        </th>
        <th>
            Status
        </th>
        <th>
        </th>
    </tr>
    @foreach (var item in Model)
    {
        if (User.IsInRole("User") && !item.Status.Equals("Canceled"))
        {
        <tr>
            <td>
                @Html.DisplayFor(modelItem => item.PromotionName)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.PromotionType)
            </td>
            <td>
                <center>@Html.DisplayFor(modelItem => item.DiscountPercent) %</center>
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.StartDate)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.EndDate)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Status)
            </td>
            <td>
                @if (User.IsInRole("Manager"))
                {
                    if (item.Status.Equals("New"))
                    {
                    @Html.ActionLink("Approve | ", "Approve", new { id = item.PromotionID });
                    }
                    else if (item.Status.Equals("Approved"))
                    {

                    }
                    else
                    {
                    @Html.ActionLink("Edit | ", "Edit", new { id = item.PromotionID });
                    }
                    @Html.ActionLink("More details | ", "Details", new { id = item.PromotionID });
                    @Html.ActionLink("Cancel | ", "Delete", new { id = item.PromotionID });
                }
            </td>
        </tr>
        }
    }
</table>
